<template>
@[
var isRichFlag=0;
var isDateFlag=0;
var isImgFlag=0;
var isFileFlag=0;
var isBGMFlag=0;
var isVideoFlag=0;
var isSelectFlag=0;
for(t in columns){
	if(scfg._col_edit!=null && scfg._col_edit[t.columnNameFormat]!=null){
		switch(scfg._edit_type[t.columnNameFormat]){
			case "3":{ isDateFlag=1;break;}
			case "5":{isSelectFlag=1;break;}
			case "8":{isImgFlag=1;break;}
			case "9":{isFileFlag=1;break;}
			case "10":{isRichFlag=1;break;}
			case "11":{isRichFlag=1;break;}
			case "12":{isBGMFlag=1;break;}
			case "15":{isVideoFlag=1;break;}
		}
	}
}
 /]
<div id="app" class="wrapper wrapper-content animated fadeInRight v-cloak" v-cloak>
	<div class="row">
		<div class="col-md-12">
			<form id="${tableNameL}Form" method="post" class="form m-t"  @submit.prevent="save()" accept-charset="UTF-8" >
				@[ for(t in pks){
					var mPk=true;
					for(t2 in columns){
						if(scfg._col_edit!=null && scfg._col_edit[t2.columnNameFormat]!=null && t.columnNameFormat==t2.columnNameFormat){
							mPk=false;
						}
					}
					if(mPk){
				/]
				<input type="hidden" name="${t.columnNameFormat}" v-model="item.${t.columnNameFormat}" />
				@[ }} /]
				<input type="hidden" name="token" v-model="item.token" />
				<input type="hidden" name="newFlag" v-model="newFlag" />
				<div class="clearfix "></div>
				<div class="col-md-6">
@[
	var _col_edit_count=0;
	for(t in columns){
	if(scfg._col_edit!=null && scfg._col_edit[t.columnNameFormat]!=null){
		_col_edit_count++;
            switch(scfg._edit_type[t.columnNameFormat]){
                case "0":{ layout("input/0_input[hidden].html",{t:t}){};break;}
                case "1":{ layout("input/1_input[text].html",{t:t}){};break;}
                case "2":{ layout("input/2_textarea.html",{t:t}){};break;}
                case "3":{ layout("input/3_input[date].html",{t:t}){};break;}
                case "4":{ layout("input/4_select.html",{t:t}){};break;}
                case "5":{ layout("input/5_select[multiple].html",{t:t}){};break;}
                case "6":{ layout("input/6_input[radio].html",{t:t}){};break;}
                case "7":{ layout("input/7_input[checkbox].html",{t:t}){};break;}
                case "8":{ layout("input/8_upload[image].html",{t:t}){};break;}
                case "9":{ layout("input/9_upload[file].html",{t:t}){};break;}
                case "12":{ layout("input/12_upload[BGM].html",{t:t}){};break;}
                case "13":{ layout("input/13_show[text].html",{t:t}){};break;}
                case "14":{ layout("input/14_show[html].html",{t:t}){};break;}
                case "15":{ layout("input/15_upload[video].html",{t:t}){};break;}
            }
	   if(_col_edit_count==parseInt(scfg._col_edit.~size/2)+1){
	   _col_edit_count=0;
 /]

				</div>
				<div class="col-md-6">
@[
		}
	}
} /]

				</div>
@[
for(t in columns){
	if(scfg._col_edit!=null && scfg._col_edit[t.columnNameFormat]!=null){
		switch(scfg._edit_type[t.columnNameFormat]){
			case "10":{
				 /]

				<div class="clearfix "></div>
				<div class="col-md-12">
				@[
				layout("input/10_editor[simple].html",{t:t}){};
				 /]

				</div>
				@[
				break;
			}
			case "11":{
				 /]

				<div class="clearfix "></div>
				<div class="col-md-12">
				@[
				layout("input/11_editor[full].html",{t:t}){};
				 /]

				</div>
				@[
				break;
			}
		}
	}
}
 /]

			  <div class="clearfix "></div>
			  <div class="col-12 text-center" style="height: 50px;">
				  <button class="btn btn-sm btn-primary" type="submit">保存</button> | <button class="btn btn-sm btn-warning" @click="lbox.closeMyBoxLayer()">返回</button>
			  </div>
			</form>
		</div>
	</div>
</div>
</template>
<script type="text/javascript">
  import '@/assets/js/style-vendor.js'

  import $ from '@/assets/js/jquery-vendor.js'
  import axios from 'axios'
  import '@/assets/js/validate/validation-vendor.js'

@[ if(isImgFlag==1||isFileFlag==1||isBGMFlag==1){ /]
  import '@/assets/css/upload.css'
@[ } /]
@[ if(isSelectFlag==1){ /]
  import '#/chosen/chosen.css'
  import '#/chosen/chosen.jquery.js'
@[ } /]
@[ if(isRichFlag==1){ /]
  import VueUeditorWrap from 'vue-ueditor-wrap'
@[ } /]
@[ if ("1"==scfg._tree) { /]
  import 'ztree'
  import '@/assets/css/zTree.css'
@[ } /]
@[ if(isDateFlag==1){ /]
  import 'layui-laydate/dist/theme/default/laydate.css'
  import laydate from 'layui-laydate'
@[ } /]
@[ if(isBGMFlag==1){ /]
  import plyr from 'plyr.js'
  import '@/assets/js/upload_single_bgm.js'
@[ } /]
@[ if(isVideoFlag==1){ /]
  import videojs from 'video.js'
@[ } /]
@[ if(isImgFlag==1){ /]
  import '@/assets/js/upload_single_pic.js'
@[ } /]
@[ if(isFileFlag==1){ /]
  import '@/assets/js/upload_single_file.js'
@[ } /]
  import {apiUtil, axiosContentType, site @[ if(isRichFlag==1){ /], ueConfig @[ } /]} from '@/assets/js/boss'

  export default {
        @[ if(isRichFlag==1){ /]
        components: {
          VueUeditorWrap
        },
        @[ } /]
        data() {
          return {
            item: {},
            newFlag: 0,
            uuidToken: '' @[ if(isRichFlag==1){ /],
            ueConfig: ueConfig
            @[ } /]
          }
        },
        mounted() {
          let that = window.$vueApp = this;
          document.getElementsByTagName('body')[0].className = 'fixed-sidebar full-height-layout';
          $('#${tableNameL}Form').validate();
          that.staff.init(function () {
            that.newFlag = sessionStorage.getItem(site.${tableNameL}.info);
              if (that.newFlag) that.uuidToken = apiUtil.guid();
              if (apiUtil.existSessionKey(site.${tableNameL}.info)) {
                that.info();
              }
          });
        @[  for(t in columns){
			if(scfg._col_edit!=null && scfg._col_edit[t.columnNameFormat]!=null){
              switch(scfg._edit_type[t.columnNameFormat]){
                  case "0":{ layout("js/0_input[hidden].js",{t:t}){};break;}
                  case "1":{ layout("js/1_input[text].js",{t:t}){};break;}
                  case "2":{ layout("js/2_textarea.js",{t:t}){};break;}
                  case "3":{ layout("js/3_input[date].js",{t:t}){};break;}
                  case "4":{ layout("js/4_select.js",{t:t}){};break;}
                  case "5":{ layout("js/5_select[multiple].js",{t:t}){};break;}
                  case "6":{ layout("js/6_input[radio].js",{t:t}){};break;}
                  case "7":{ layout("js/7_input[checkbox].js",{t:t}){};break;}
                  case "8":{ layout("js/8_upload[image].js",{t:t}){};break;}
                  case "9":{ layout("js/9_upload[file].js",{t:t}){};break;}

                  case "12":{layout("js/12_upload[BGM].js",{t:t}){};break;}
                  case "13":{layout("js/input/13_show[text].js",{t:t}){};break;}
                  case "14":{layout("js/input/14_show[html].js",{t:t}){};break;}
                  case "15":{layout("js/15_upload[video].js",{t:t}){};break;}
              }
            }
        } /]
        },
        methods: {
            info() {
                let that = this;
                axios.get(site.${tableNameL}.info + sessionStorage.getItem(site.${tableNameL}.info), {}).then(function (response) {
                     const result = response.data;
                    if (result.code === 0) {
                        that.item = result.data;
                    } else {
                        alert(result.message);
                    }
                });
            },
            save() {
                let that = this;
                if ($('#${tableNameL}Form').valid()) {
                     axios.post(site.${tableNameL}.save, $('#${tableNameL}Form').serialize(),
                     axiosContentType.xWwwFormUrlencoded).then(function (response) {
                        const result = response.data;
                        // console.info("获取数据.." + JSON.stringify(result));
                        if (result.code === 0) {
                            parent.$vueApp.page();
                            alert('保存成功!');
                            that.lbox.closeMyBoxLayer()
                        } else {
                            alert(result.message);
                        }
                    });
                }
            }
            @[ if ("1"==scfg._tree) { /]
            ,
            loadTree(){

            }
            @[ } /]
        }
    }
</script>

